﻿using System.Drawing;

namespace AESAlgNet
{
    public static class ImageTools
    {
        // Convert Bitmap to byte array in RGB format
        public static byte[] BitmapToRGBByteArray(Bitmap bitmap)
        {
            int width = bitmap.Width;
            int height = bitmap.Height;
            byte[] rgbBuffer = new byte[width * height * 3];
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Color pixel = bitmap.GetPixel(x, y);
                    int index = (y * width + x) * 3;
                    rgbBuffer[index] = pixel.R;
                    rgbBuffer[index + 1] = pixel.G;
                    rgbBuffer[index + 2] = pixel.B;
                }
            }
            return rgbBuffer;
        }


    }
}
